/**
 * @file message
 */
import isPc from 'src/common/utils/isPc';
import { ElMessage } from 'element-plus';

let customClass = ''; // 自定义类
const duration = 3000; // 显示时间，单位为毫秒

// 获取弹出层类名
const getCustomClass = () => {
  customClass = isPc ? '' : 'message-toast';
  return customClass;
};

// 显示提示
const showMessage = (type, message) => {
  ElMessage({
    message,
    type,
    duration,
    'custom-class': customClass || getCustomClass()
  });
};

const showInfo = message => {
  showMessage('info', message);
};
const showSuccess = message => {
  showMessage('success', message);
};
const showWarning = message => {
  showMessage('warning', message);
};
const showError = message => {
  showMessage('error', message);
};

export default {
  showInfo,
  showSuccess,
  showWarning,
  showError,
  duration
};
